Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of quantiles for messenger guides [WIP] #2988

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

vitkl
Copy link
Contributor

@vitkl vitkl commented Dec 11, 2021

This PR contributes the implementation of quantiles for messenger guides - which resembles how this is done in AutoNormal. I see certain errors that I don't know how to address (https://github.com/pyro-ppl/pyro/runs/4490764371?check_suite_focus=true#step:5:22410) - namely, the messenger guide tries to expand returned quantiles new.v = self.v.expand(batch_shape + self.event_shape). This can potentially be addressed by running a for loop over requested quantiles like this:

def quantiles(self, quantiles, *args, **kwargs):
        self._computing_quantiles = True
        try:
            for i, q in enumerate(quantiles):
                self._quantile_values = q
                _quantiles_1 = self(*args, **kwargs)
                if i == 0:
                    _quantiles = {k: [v] for k, v in _quantiles_1.items()}
                else:
                    _quantiles_1
                    # add new quantile
                     _quantiles = {k: _quantiles[k] + [_quantiles_1[k]] for k in _quantiles.keys()}
               
            return  {k: torch.tensor(v, dtype=_quantiles_1[k].dtype, device=_quantiles_1[k].device) for k, v in _quantiles.items()}
        finally:
            self._computing_quantiles = False

Please let me know what you think @fritzo

@fritzo fritzo added the WIP label Dec 11, 2021
Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sketching this @vitkl. The approach seems reasonable, but I'm unsure why the shapes are erroring.

@vitkl
Copy link
Contributor Author

vitkl commented Jan 25, 2022

Is it possible to restart the checks? Maybe the issue resolved itself with new changes to pyro/pytorch?

vitkl added a commit to BayraktarLab/cell2location that referenced this pull request Jan 25, 2022
@fritzo
Copy link
Member

fritzo commented Jan 25, 2022

not sure how to restart in github actions, but you could merge Pyro dev branch and push, that should rerun ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants